package fpga_generation.java_base;

public abstract class base_component
{
	public String name;
	public String type;
	private boolean isConnected;
	public base_clock_source clockSource;
	public String interfaceName;
	public String clockSink;
	
	public base_component(String name)
	{
		this.name = name;
		this.type = "undefined";
		this.isConnected = false;
		if (base_project.baseClock != null) {
			this.clockSource = base_project.baseClock;
		}
	}
	
	public String easyClockConnect()
	{
		return "add_connection " + clockSource.getInterface() + "/" + name + "." + clockSink + "\n";
	}
	
	public base_component(String name, String interfaceName)
	{
		this.name = name;
		this.type = "undefined";
		this.isConnected = false;
		if (base_project.baseClock != null) {
			this.clockSource = base_project.baseClock;
		}
		this.interfaceName = interfaceName;
	}
	
	public String getName()
	{
		return name;
	}
	
	public String getInterface() 
	{
		return name + "." + interfaceName;
	}
	
	public void setClockSource(String interfaceName, base_clock_source src) {
		clockSource = src;
	}
	
	public String writeRepr(int impl, int round) 
	{
		return "";
	}
	
	public String set_parameter(int impl, String parameterName, String parameterValue )
	{
		return "set_parameter " + name + " " + parameterName + " \"" + parameterValue + "\"\n";
	}
	
	public String set_parameter(int impl, String parameterName, boolean value )
	{
		String strRep = "false";
		if (value) {
			strRep = "true";
		}
		return "set_parameter " + name + " " + parameterName + " \"" + strRep + "\"\n";
	}
	
	public String set_parameter(int impl, String parameterName, int value )
	{
		return "set_parameter " + name + " " + parameterName + " " + value + "\n";
	}
	
	public String add_module(int impl)
	{
		return "add_module " + type + " " + name + "\n";
	}	
}